{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor(-0.0888)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import torch\n",
    "volume=torch.randn(2)\n",
    "price=torch.randn(2)\n",
    "volume[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "can only concatenate list (not \"float\") to list",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m/tmp/ipykernel_2631037/4037277190.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdistributions\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnormal\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mNormal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtensor\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mvolume\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mprice\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtensor\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrelu\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvolume\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;36m0.01\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrelu\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprice\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;36m0.01\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m: can only concatenate list (not \"float\") to list"
     ]
    }
   ],
   "source": [
    "dis=torch.distributions.normal.Normal(torch.tensor([volume[0],price[0]]),torch.tensor([torch.relu(volume[1])+0.01,torch.relu(price[1])]+0.01))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([-1.3098e+00,  5.0000e+04])"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m = torch.distributions.normal.Normal(torch.tensor([0.0,50000]), torch.tensor([1.0,2]))\n",
    "m.sample()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "torch.randn(2)[0].shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([-1.3902, -2.1485])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "torch.cat((torch.randn(2)[0].unsqueeze(0),torch.randn(2)[0].unsqueeze(0)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor(-1.)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "torch.tensor([-1]).float().mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "l=[1,2,3,4,5]\n",
    "old=l.copy()\n",
    "l.pop(0)\n",
    "l.append(6)\n",
    "new=l"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "old"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2, 3, 4, 5, 6]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/sunshuo/miniconda3/envs/TradeMaster/lib/python3.7/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "tensor(1)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import torch\n",
    "1-torch.tensor(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df=pd.read_csv(\"/home/sunshuo/qml/TradeMaster-1/data/data/OE_BTC/test.csv\",index_col=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>system_time</th>\n",
       "      <th>midpoint</th>\n",
       "      <th>spread</th>\n",
       "      <th>buys</th>\n",
       "      <th>sells</th>\n",
       "      <th>bids_distance_0</th>\n",
       "      <th>bids_distance_1</th>\n",
       "      <th>bids_distance_2</th>\n",
       "      <th>bids_distance_3</th>\n",
       "      <th>bids_distance_4</th>\n",
       "      <th>...</th>\n",
       "      <th>asks_market_notional_5</th>\n",
       "      <th>asks_market_notional_6</th>\n",
       "      <th>asks_market_notional_7</th>\n",
       "      <th>asks_market_notional_8</th>\n",
       "      <th>asks_market_notional_9</th>\n",
       "      <th>asks_market_notional_10</th>\n",
       "      <th>asks_market_notional_11</th>\n",
       "      <th>asks_market_notional_12</th>\n",
       "      <th>asks_market_notional_13</th>\n",
       "      <th>asks_market_notional_14</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2021-04-17 00:38:00.281751+00:00</td>\n",
       "      <td>61357.035</td>\n",
       "      <td>0.01</td>\n",
       "      <td>297283.360397</td>\n",
       "      <td>131197.795034</td>\n",
       "      <td>-8.149025e-08</td>\n",
       "      <td>-0.000015</td>\n",
       "      <td>-0.000109</td>\n",
       "      <td>-0.000135</td>\n",
       "      <td>-0.000138</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2021-04-17 00:39:00.281751+00:00</td>\n",
       "      <td>61399.575</td>\n",
       "      <td>0.01</td>\n",
       "      <td>580371.169864</td>\n",
       "      <td>422586.530538</td>\n",
       "      <td>-8.143379e-08</td>\n",
       "      <td>-0.000044</td>\n",
       "      <td>-0.000052</td>\n",
       "      <td>-0.000056</td>\n",
       "      <td>-0.000122</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2021-04-17 00:40:00.281751+00:00</td>\n",
       "      <td>61319.665</td>\n",
       "      <td>0.05</td>\n",
       "      <td>70460.909745</td>\n",
       "      <td>128334.135492</td>\n",
       "      <td>-4.076996e-07</td>\n",
       "      <td>-0.000023</td>\n",
       "      <td>-0.000027</td>\n",
       "      <td>-0.000062</td>\n",
       "      <td>-0.000062</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2021-04-17 00:41:00.281751+00:00</td>\n",
       "      <td>61396.515</td>\n",
       "      <td>0.01</td>\n",
       "      <td>464370.628504</td>\n",
       "      <td>431485.596255</td>\n",
       "      <td>-8.143785e-08</td>\n",
       "      <td>-0.000225</td>\n",
       "      <td>-0.000241</td>\n",
       "      <td>-0.000249</td>\n",
       "      <td>-0.000253</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2021-04-17 00:42:00.281751+00:00</td>\n",
       "      <td>61331.785</td>\n",
       "      <td>0.01</td>\n",
       "      <td>215821.000056</td>\n",
       "      <td>47201.539144</td>\n",
       "      <td>-8.152379e-08</td>\n",
       "      <td>-0.000007</td>\n",
       "      <td>-0.000041</td>\n",
       "      <td>-0.000058</td>\n",
       "      <td>-0.000076</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3418</th>\n",
       "      <td>2021-04-19 09:49:00.386544+00:00</td>\n",
       "      <td>56894.195</td>\n",
       "      <td>0.01</td>\n",
       "      <td>119386.378686</td>\n",
       "      <td>50993.869682</td>\n",
       "      <td>-8.788243e-08</td>\n",
       "      <td>-0.000028</td>\n",
       "      <td>-0.000151</td>\n",
       "      <td>-0.000171</td>\n",
       "      <td>-0.000177</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3419</th>\n",
       "      <td>2021-04-19 09:50:00.386544+00:00</td>\n",
       "      <td>56878.090</td>\n",
       "      <td>6.54</td>\n",
       "      <td>72056.866567</td>\n",
       "      <td>154209.154442</td>\n",
       "      <td>-5.749138e-05</td>\n",
       "      <td>-0.000058</td>\n",
       "      <td>-0.000068</td>\n",
       "      <td>-0.000094</td>\n",
       "      <td>-0.000101</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3420</th>\n",
       "      <td>2021-04-19 09:51:00.386544+00:00</td>\n",
       "      <td>56944.085</td>\n",
       "      <td>2.57</td>\n",
       "      <td>93839.070004</td>\n",
       "      <td>30850.792037</td>\n",
       "      <td>-2.256600e-05</td>\n",
       "      <td>-0.000028</td>\n",
       "      <td>-0.000088</td>\n",
       "      <td>-0.000093</td>\n",
       "      <td>-0.000100</td>\n",
       "      <td>...</td>\n",
       "      <td>549.880005</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3421</th>\n",
       "      <td>2021-04-19 09:52:00.386544+00:00</td>\n",
       "      <td>56873.165</td>\n",
       "      <td>0.01</td>\n",
       "      <td>336640.772382</td>\n",
       "      <td>119825.333954</td>\n",
       "      <td>-8.791493e-08</td>\n",
       "      <td>-0.000069</td>\n",
       "      <td>-0.000128</td>\n",
       "      <td>-0.000189</td>\n",
       "      <td>-0.000203</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3422</th>\n",
       "      <td>2021-04-19 09:53:00.386544+00:00</td>\n",
       "      <td>56820.445</td>\n",
       "      <td>0.01</td>\n",
       "      <td>31188.586850</td>\n",
       "      <td>83559.517906</td>\n",
       "      <td>-8.799650e-08</td>\n",
       "      <td>-0.000039</td>\n",
       "      <td>-0.000088</td>\n",
       "      <td>-0.000113</td>\n",
       "      <td>-0.000143</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3423 rows × 155 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                           system_time   midpoint  spread           buys  \\\n",
       "0     2021-04-17 00:38:00.281751+00:00  61357.035    0.01  297283.360397   \n",
       "1     2021-04-17 00:39:00.281751+00:00  61399.575    0.01  580371.169864   \n",
       "2     2021-04-17 00:40:00.281751+00:00  61319.665    0.05   70460.909745   \n",
       "3     2021-04-17 00:41:00.281751+00:00  61396.515    0.01  464370.628504   \n",
       "4     2021-04-17 00:42:00.281751+00:00  61331.785    0.01  215821.000056   \n",
       "...                                ...        ...     ...            ...   \n",
       "3418  2021-04-19 09:49:00.386544+00:00  56894.195    0.01  119386.378686   \n",
       "3419  2021-04-19 09:50:00.386544+00:00  56878.090    6.54   72056.866567   \n",
       "3420  2021-04-19 09:51:00.386544+00:00  56944.085    2.57   93839.070004   \n",
       "3421  2021-04-19 09:52:00.386544+00:00  56873.165    0.01  336640.772382   \n",
       "3422  2021-04-19 09:53:00.386544+00:00  56820.445    0.01   31188.586850   \n",
       "\n",
       "              sells  bids_distance_0  bids_distance_1  bids_distance_2  \\\n",
       "0     131197.795034    -8.149025e-08        -0.000015        -0.000109   \n",
       "1     422586.530538    -8.143379e-08        -0.000044        -0.000052   \n",
       "2     128334.135492    -4.076996e-07        -0.000023        -0.000027   \n",
       "3     431485.596255    -8.143785e-08        -0.000225        -0.000241   \n",
       "4      47201.539144    -8.152379e-08        -0.000007        -0.000041   \n",
       "...             ...              ...              ...              ...   \n",
       "3418   50993.869682    -8.788243e-08        -0.000028        -0.000151   \n",
       "3419  154209.154442    -5.749138e-05        -0.000058        -0.000068   \n",
       "3420   30850.792037    -2.256600e-05        -0.000028        -0.000088   \n",
       "3421  119825.333954    -8.791493e-08        -0.000069        -0.000128   \n",
       "3422   83559.517906    -8.799650e-08        -0.000039        -0.000088   \n",
       "\n",
       "      bids_distance_3  bids_distance_4  ...  asks_market_notional_5  \\\n",
       "0           -0.000135        -0.000138  ...                0.000000   \n",
       "1           -0.000056        -0.000122  ...                0.000000   \n",
       "2           -0.000062        -0.000062  ...                0.000000   \n",
       "3           -0.000249        -0.000253  ...                0.000000   \n",
       "4           -0.000058        -0.000076  ...                0.000000   \n",
       "...               ...              ...  ...                     ...   \n",
       "3418        -0.000171        -0.000177  ...                0.000000   \n",
       "3419        -0.000094        -0.000101  ...                0.000000   \n",
       "3420        -0.000093        -0.000100  ...              549.880005   \n",
       "3421        -0.000189        -0.000203  ...                0.000000   \n",
       "3422        -0.000113        -0.000143  ...                0.000000   \n",
       "\n",
       "      asks_market_notional_6  asks_market_notional_7  asks_market_notional_8  \\\n",
       "0                        0.0                     0.0                     0.0   \n",
       "1                        0.0                     0.0                     0.0   \n",
       "2                        0.0                     0.0                     0.0   \n",
       "3                        0.0                     0.0                     0.0   \n",
       "4                        0.0                     0.0                     0.0   \n",
       "...                      ...                     ...                     ...   \n",
       "3418                     0.0                     0.0                     0.0   \n",
       "3419                     0.0                     0.0                     0.0   \n",
       "3420                     0.0                     0.0                     0.0   \n",
       "3421                     0.0                     0.0                     0.0   \n",
       "3422                     0.0                     0.0                     0.0   \n",
       "\n",
       "      asks_market_notional_9  asks_market_notional_10  \\\n",
       "0                        0.0                      0.0   \n",
       "1                        0.0                      0.0   \n",
       "2                        0.0                      0.0   \n",
       "3                        0.0                      0.0   \n",
       "4                        0.0                      0.0   \n",
       "...                      ...                      ...   \n",
       "3418                     0.0                      0.0   \n",
       "3419                     0.0                      0.0   \n",
       "3420                     0.0                      0.0   \n",
       "3421                     0.0                      0.0   \n",
       "3422                     0.0                      0.0   \n",
       "\n",
       "      asks_market_notional_11  asks_market_notional_12  \\\n",
       "0                         0.0                      0.0   \n",
       "1                         0.0                      0.0   \n",
       "2                         0.0                      0.0   \n",
       "3                         0.0                      0.0   \n",
       "4                         0.0                      0.0   \n",
       "...                       ...                      ...   \n",
       "3418                      0.0                      0.0   \n",
       "3419                      0.0                      0.0   \n",
       "3420                      0.0                      0.0   \n",
       "3421                      0.0                      0.0   \n",
       "3422                      0.0                      0.0   \n",
       "\n",
       "      asks_market_notional_13  asks_market_notional_14  \n",
       "0                         0.0                      0.0  \n",
       "1                         0.0                      0.0  \n",
       "2                         0.0                      0.0  \n",
       "3                         0.0                      0.0  \n",
       "4                         0.0                      0.0  \n",
       "...                       ...                      ...  \n",
       "3418                      0.0                      0.0  \n",
       "3419                      0.0                      0.0  \n",
       "3420                      0.0                      0.0  \n",
       "3421                      0.0                      0.0  \n",
       "3422                      0.0                      0.0  \n",
       "\n",
       "[3423 rows x 155 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_day=df.loc[1, :]\n",
    "data =df.copy().loc[1, :]\n",
    "data[\"order_money\"]=data[\"buys\"]+data[\"sells\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1002957.7004021206"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data=df.copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "data=data[[\n",
    "        'midpoint', 'spread', 'buys', 'sells', 'bids_distance_0',\n",
    "        'bids_distance_1', 'bids_distance_2', 'bids_distance_3',\n",
    "        'bids_distance_4', 'bids_distance_5', 'bids_distance_6',\n",
    "        'bids_distance_7', 'bids_distance_8', 'bids_distance_9',\n",
    "        'bids_distance_10', 'bids_distance_11', 'bids_distance_12',\n",
    "        'bids_distance_13', 'bids_distance_14', 'bids_notional_0',\n",
    "        'bids_notional_1', 'bids_notional_2', 'bids_notional_3',\n",
    "        'bids_notional_4', 'bids_notional_5', 'bids_notional_6',\n",
    "        'bids_notional_7', 'bids_notional_8', 'bids_notional_9',\n",
    "        'bids_notional_10', 'bids_notional_11', 'bids_notional_12',\n",
    "        'bids_notional_13', 'bids_notional_14', 'bids_cancel_notional_0',\n",
    "        'bids_cancel_notional_1', 'bids_cancel_notional_2',\n",
    "        'bids_cancel_notional_3', 'bids_cancel_notional_4',\n",
    "        'bids_cancel_notional_5', 'bids_cancel_notional_6',\n",
    "        'bids_cancel_notional_7', 'bids_cancel_notional_8',\n",
    "        'bids_cancel_notional_9', 'bids_cancel_notional_10',\n",
    "        'bids_cancel_notional_11', 'bids_cancel_notional_12',\n",
    "        'bids_cancel_notional_13', 'bids_cancel_notional_14',\n",
    "        'bids_limit_notional_0', 'bids_limit_notional_1',\n",
    "        'bids_limit_notional_2', 'bids_limit_notional_3',\n",
    "        'bids_limit_notional_4', 'bids_limit_notional_5',\n",
    "        'bids_limit_notional_6', 'bids_limit_notional_7',\n",
    "        'bids_limit_notional_8', 'bids_limit_notional_9',\n",
    "        'bids_limit_notional_10', 'bids_limit_notional_11',\n",
    "        'bids_limit_notional_12', 'bids_limit_notional_13',\n",
    "        'bids_limit_notional_14', 'bids_market_notional_0',\n",
    "        'bids_market_notional_1', 'bids_market_notional_2',\n",
    "        'bids_market_notional_3', 'bids_market_notional_4',\n",
    "        'bids_market_notional_5', 'bids_market_notional_6',\n",
    "        'bids_market_notional_7', 'bids_market_notional_8',\n",
    "        'bids_market_notional_9', 'bids_market_notional_10',\n",
    "        'bids_market_notional_11', 'bids_market_notional_12',\n",
    "        'bids_market_notional_13', 'bids_market_notional_14',\n",
    "        'asks_distance_0', 'asks_distance_1', 'asks_distance_2',\n",
    "        'asks_distance_3', 'asks_distance_4', 'asks_distance_5',\n",
    "        'asks_distance_6', 'asks_distance_7', 'asks_distance_8',\n",
    "        'asks_distance_9', 'asks_distance_10', 'asks_distance_11',\n",
    "        'asks_distance_12', 'asks_distance_13', 'asks_distance_14',\n",
    "        'asks_notional_0', 'asks_notional_1', 'asks_notional_2',\n",
    "        'asks_notional_3', 'asks_notional_4', 'asks_notional_5',\n",
    "        'asks_notional_6', 'asks_notional_7', 'asks_notional_8',\n",
    "        'asks_notional_9', 'asks_notional_10', 'asks_notional_11',\n",
    "        'asks_notional_12', 'asks_notional_13', 'asks_notional_14',\n",
    "        'asks_cancel_notional_0', 'asks_cancel_notional_1',\n",
    "        'asks_cancel_notional_2', 'asks_cancel_notional_3',\n",
    "        'asks_cancel_notional_4', 'asks_cancel_notional_5',\n",
    "        'asks_cancel_notional_6', 'asks_cancel_notional_7',\n",
    "        'asks_cancel_notional_8', 'asks_cancel_notional_9',\n",
    "        'asks_cancel_notional_10', 'asks_cancel_notional_11',\n",
    "        'asks_cancel_notional_12', 'asks_cancel_notional_13',\n",
    "        'asks_cancel_notional_14', 'asks_limit_notional_0',\n",
    "        'asks_limit_notional_1', 'asks_limit_notional_2',\n",
    "        'asks_limit_notional_3', 'asks_limit_notional_4',\n",
    "        'asks_limit_notional_5', 'asks_limit_notional_6',\n",
    "        'asks_limit_notional_7', 'asks_limit_notional_8',\n",
    "        'asks_limit_notional_9', 'asks_limit_notional_10',\n",
    "        'asks_limit_notional_11', 'asks_limit_notional_12',\n",
    "        'asks_limit_notional_13', 'asks_limit_notional_14',\n",
    "        'asks_market_notional_0', 'asks_market_notional_1',\n",
    "        'asks_market_notional_2', 'asks_market_notional_3',\n",
    "        'asks_market_notional_4', 'asks_market_notional_5',\n",
    "        'asks_market_notional_6', 'asks_market_notional_7',\n",
    "        'asks_market_notional_8', 'asks_market_notional_9',\n",
    "        'asks_market_notional_10', 'asks_market_notional_11',\n",
    "        'asks_market_notional_12', 'asks_market_notional_13',\n",
    "        'asks_market_notional_14'\n",
    "    ]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "580371.1698638686"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "max(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "system_time                2021-04-17 00:39:00.281751+00:00\n",
       "midpoint                                          61399.575\n",
       "spread                                                 0.01\n",
       "buys                                          580371.169864\n",
       "sells                                         422586.530538\n",
       "                                         ...               \n",
       "asks_market_notional_11                                 0.0\n",
       "asks_market_notional_12                                 0.0\n",
       "asks_market_notional_13                                 0.0\n",
       "asks_market_notional_14                                 0.0\n",
       "order_money                                  1002957.700402\n",
       "Name: 1, Length: 156, dtype: object"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for /: 'list' and 'int'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m/tmp/ipykernel_2776988/2571752222.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for /: 'list' and 'int'"
     ]
    }
   ],
   "source": [
    "[1,2,3,4]/5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/sunshuo/miniconda3/envs/TradeMaster/lib/python3.7/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "20"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import torch\n",
    "torch.tensor([20,6])[0].item()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "a=[123,3,2,12,123,123,123]\n",
    "max_value=max([123,3,2,12,123,123,123])\n",
    "index=a.index(max_value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.7.13 ('TradeMaster')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.13"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "a1f97403911abd3f02553c8f2b0c54537fddc7efadd9f5d3e31784db6e40c347"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
